import { _decorator, Component, instantiate, Node, Vec3 } from 'cc';
import { PromptScore } from './PromptScore';
import { ResMgr } from '../Mgr/ResMgr';
import { AssetList } from '../Global';
const { ccclass, property } = _decorator;

@ccclass('EleScoreLoad')
/**
 * 分数层
 */
export class EleScoreLoad extends Component {

    //分数数组
    public ScoreArr: Node[] = [];

    //
    public NouseArr: Node[] = [];

    /**
     * 获取分数
     */
    public GetScore(_score: number, _pos: Vec3) {
        let sing_score: Node = null
        if (this.NouseArr.length > 0) {
            sing_score = this.NouseArr.pop();
        } else {
            sing_score = instantiate(ResMgr.Instance.Prefabs[AssetList.Prefabs.GameSingleScore])
        }
        this.node.addChild(sing_score);
        sing_score.setPosition(_pos);
        sing_score.getComponent(PromptScore).ElseScoreLoad = this.node;
        sing_score.getComponent(PromptScore).UpdateScore(_score);
        this.ScoreArr.push(sing_score);
    }

}


